

package com.springcloud.sc.ucpv5.client.commondata;

import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.springcloud.sc.ucpv5.client.commondata.tree.IDcsTreeNode;
import com.springcloud.sc.ucpv5.client.contentmain.MainConstant;

/**
 * Comments : 6-17
 */

public class RootModel implements IDcsTreeNode {
	private ArrayList children = new ArrayList();

	public void setParent(IDcsTreeNode parent) {

	}

	public void addChild(List list) {
		for (Object tempNode : list) {
			IDcsTreeNode node = (IDcsTreeNode) tempNode;
			if (!children.contains(node)) {
				children.add(node);
				node.setParent(this);
			}
		}
	}

	public void addChild(IDcsTreeNode node) {
		addChild(node, true);
	}

	public void addChild(IDcsTreeNode node, boolean isChild) {
		if (!children.contains(node)) {
			children.add(node);
			if (isChild)
				node.setParent(this);
		}
	}

	public boolean removeChild(IDcsTreeNode node) {
		boolean ret = children.remove(node);
		return ret;
	}

	public void clean() {
		if (children != null) {
			children.clear();
		}
	}

	public RootModel() {
		super();
	}

	public ArrayList getChildren() {
		ArrayList list = new ArrayList();
		list.addAll(children);
		return list;
	}

	public ArrayList getTrueChildren() {
		return children;
	}

	public Object getParent() {
		return null;
	}

	public boolean hasChildren() {
		return children.size() > 0;
	}

	public int getLevel() {
		return 0;
	}

	public void setLevel(int level) {
	}

	public void invokeAction(int actionId) {
		switch (actionId) {
		case MainConstant.ACTION_ID_REFRESH_DATA:
		case MainConstant.ACTION_ID_REFRESH_DATA_NO_STATUS:
			// SecuResult result = new SecuResult();
			// ArrayList<ADynamicProgressHandle> taskList =
			// DcsDataLoaderHelp.getRefreshProgressHandle(this,result);
			//
			// DynamicProgressDialog dlg = new
			// DynamicProgressDialog(DcsMainUtil.getStrRes("Task.refreshData"),taskList);
			// dlg.runInUI();
			// DcsDataBuffer.getInstance().onRefreshData(this);
			// result.promptResult();
			break;
		}
	}

	public boolean isBlink() {
		// TODO Auto-generated method stub
		return false;
	}

	public String getFieldText(int fieldId) {
		// TODO Auto-generated method stub
		return null;
	}

	public int getIdField(int fieldId) {
		// TODO Auto-generated method stub
		return 0;
	}

	public List getModelSourceConnections(boolean isLocal) {
		return Collections.EMPTY_LIST;
	}

	public List getModelTargetConnections(boolean isLocal) {
		return Collections.EMPTY_LIST;
	}

}
